package com.asiainfo_linkage.service;

import java.util.List;

import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.pager.Pager;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.service.EntityService;

import com.asiainfo_linkage.model.AddMember;


@IocBean
public class MemberQueryService extends EntityService<AddMember>{
	
	@Inject
	protected Dao dao;
	/**
	 * 查询初始页面当前是否有列表数据展示。
	 */
	public List<AddMember> pageQuery(AddMember memberQuery, Pager pager){
		if(memberQuery==null){
			memberQuery = new AddMember();
		}
		if(pager==null){
			pager = new Pager();
		}
		
		pager.setRecordCount(this.dao().count(AddMember.class, Cnd.where("GROUP_ID", "=", memberQuery.getGROUP_ID())));
		
		return this.dao().query(AddMember.class, Cnd.where("GROUP_ID", "=", memberQuery.getGROUP_ID()), pager);
	}
	
	/**
	 * 根据组ID查询组员信息列表。
	 * @param groupId 组ID。
	 * @return 组员列表。
	 */
	public List<AddMember> findByGroupId(long groupId){
		return this.dao().query(AddMember.class, Cnd.where("GROUP_ID", "=", groupId));
	}

	
	public List<AddMember> pageQueryMemberId(AddMember memberQuery, Pager pager){
		if(memberQuery==null){
			memberQuery = new AddMember();
		}
		if(pager==null){
			pager = new Pager();
		}
		
		pager.setRecordCount(this.dao().count(AddMember.class, Cnd.where("MEMBER_ID", "=", memberQuery.getMEMBER_ID())));
		
		return this.dao().query(AddMember.class, Cnd.where("MEMBER_ID", "=", memberQuery.getMEMBER_ID()), pager);
	}

}

